let navsecond = document.querySelector('.nav-second-body')
ajax({
  method: "get",
  url: "stage-api/website/getProductMenuInfo",
  success: function(res){
    console.log(res)
    for (let i = 0; i < res.data.length; i++) {
      if (i == 4) {
        continue;
      }else if(i == 6){
        continue;
      }else{
         navsecond.innerHTML += `<li class="nav-second-item" onclick="detail('${res.data[i].productId}')">
                                <div class="navsec-bod">
                                  <img src="${res.data[i].menuIcon.split("?")[0]}">
                                  <div>${res.data[i].productName}</div>
                                </div>
                              </li>`
      }
    }
  }
})

function detail(productId) {
      location.href = `product.html?productId=${productId}`
    }

let tabwrap = document.querySelector(".tab-wrap ul")
ajax({
  method: "get",
  url: "stage-api/website/dict/data/list",
  params: {
    dictType: "job_type",
  },
  success: function(res){
    console.log(res)
    for (let i = 0; i < res.rows.length; i++) {
      tabwrap.innerHTML += `<li class="item" onclick="job(${res.rows[i].dictValue})">
                              <font>${res.rows[i].dictLabel}</font>
                              <span class="line"></span>
                            </li>`
    }
  }
})
// let becheak = document.querySelectorAll('.tab-wrap ul li')

function job(jobid){
  let jobtype =  `${jobid}`
  let jobitem = document.querySelector('.list-wrap ul')
$('.tab-wrap ul li').eq(jobtype).addClass('item-on').siblings().removeClass('item-on')
  jobitem.innerHTML = ""
  ajax({
    method: "get",
    url: "stage-api/website/job/list",
    params: {
      pageNum: 1,
      pageSize: 6,
      jobType: jobtype,
    },
    success: function(res){
      console.log(res)
      for (let i = 0; i < res.rows.length; i++) {
        jobitem.innerHTML += `<li class="item-wrap page1">
                                <div class="item">
                                  <div class="title">${res.rows[i].postName}</div>
                                  <ul class="label-wrap clearfix">
                                    <li class="label-item">${res.rows[i].jobAddress}</li>
                                    <li class="label-item">${res.rows[i].jobRequireAge}</li>
                                    <li class="label-item">
                                      <span></span>
                                    </li>
                                  </ul>
                                  <div class="salary">${res.rows[i].salary}</div>
                                  <div class="infor">${res.rows[i].jobDescription}</div>
                                  <div class="btn">申请职位</div>
                                </div>
                              </li>`
        if (`${res.rows[i].jobRequireEdu}` == 1) {
          document.querySelectorAll('.label-item span')[i].innerText = "专科"
        }else{
          document.querySelectorAll('.label-item span')[i].innerText = "本科"
        }
      }
      document.querySelector('.c-page .num').innerText = `共 ${res.total} 页`
    }
  })


  ajax({
    method: "get",
    url: "stage-api/website/job/list",
    params: {
      pageNum: 2,
      pageSize: 6,
      jobType: jobtype,
    },
    success: function(res){
      console.log(res)
      for (let i = 0; i < res.rows.length; i++) {
        jobitem.innerHTML += `<li class="item-wrap page2">
                                <div class="item">
                                  <div class="title">${res.rows[i].postName}</div>
                                  <ul class="label-wrap clearfix">
                                    <li class="label-item">${res.rows[i].jobAddress}</li>
                                    <li class="label-item">${res.rows[i].jobRequireAge}</li>
                                    <li class="label-item">
                                      <span></span>
                                    </li>
                                  </ul>
                                  <div class="salary">${res.rows[i].salary}</div>
                                  <div class="infor">${res.rows[i].jobDescription}</div>
                                  <div class="btn">申请职位</div>
                                </div>
                              </li>`
        if (`${res.rows[i].jobRequireEdu}` == 1) {
          document.querySelectorAll('.label-item span')[i].innerText = "专科"
        }else{
          document.querySelectorAll('.label-item span')[i].innerText = "本科"
        }
      }
    }
  })

  ajax({
    method: "get",
    url: "stage-api/website/job/list",
    params: {
      pageNum: 3,
      pageSize: 6,
      jobType: jobtype,
    },
    success: function(res){
      console.log(res)
      for (let i = 0; i < res.rows.length; i++) {
        jobitem.innerHTML += `<li class="item-wrap page3">
                                <div class="item">
                                  <div class="title">${res.rows[i].postName}</div>
                                  <ul class="label-wrap clearfix">
                                    <li class="label-item">${res.rows[i].jobAddress}</li>
                                    <li class="label-item">${res.rows[i].jobRequireAge}</li>
                                    <li class="label-item">
                                      <span></span>
                                    </li>
                                  </ul>
                                  <div class="salary">${res.rows[i].salary}</div>
                                  <div class="infor">${res.rows[i].jobDescription}</div>
                                  <div class="btn">申请职位</div>
                                </div>
                              </li>`
        if (`${res.rows[i].jobRequireEdu}` == 1) {
          document.querySelectorAll('.label-item span')[i].innerText = "专科"
        }else{
          document.querySelectorAll('.label-item span')[i].innerText = "本科"
        }
      }
    }
  })

let number = document.querySelectorAll('.pagenumber')
number[1].onclick = function(){
  number[0].className = "pagenumber"
  number[2].className = "pagenumber"
  this.className = "pagenumber active"
  // $(this).addClass('.active').siblings().removeClass('active')
  $(".page3").css("display","none")
  $(".page1").css("display","none")
  $(".page2").css("display","block")
  $(".nextpage").attr("disabled", true)
  $(".lestpage").attr("disabled", false)
}
number[0].onclick = function(){
  number[1].className = "pagenumber"
  number[2].className = "pagenumber"
  this.className = "pagenumber active"
  // $(this).addClass('.active').siblings().removeClass('active')
  $(".page2").css("display","none")
  $(".page1").css("display","block")
  $(".page3").css("display","none")
  $(".nextpage").attr("disabled", false)
  $(".lestpage").attr("disabled", true)
}
number[2].onclick = function(){
  number[1].className = "pagenumber"
  number[0].className = "pagenumber"
  this.className = "pagenumber active"
  // $(this).addClass('.active').siblings().removeClass('active')
  $(".page2").css("display","none")
  $(".page3").css("display","block")
  $(".page1").css("display","none")
  $(".nextpage").attr("disabled", false)
  $(".lestpage").attr("disabled", true)
}
let act = document.querySelector('.action')
$(".nextpage").click(function() {
  act.nextElementSibling.onclick()
})
$(".lestpage").click(function() {
  act.previousElementSibling.onclick()
})

}
job(1)